<template>
    <div class="newTeachMaterial">
      <el-form ref="form" :model="form" label-width="100px" :rules="rules">
        <el-form-item label="教材编号" prop="textbookId">
          <el-input v-model="form.textbookId" name="user"></el-input>
        </el-form-item>
        <el-form-item label="教材名称" prop="textbookName">
          <el-input v-model="form.textbookName"></el-input>
        </el-form-item>
        <el-form-item label="出版社" prop="publishingHouse">
          <el-input v-model="form.publishingHouse"></el-input>
        </el-form-item>
        <el-form-item label="作者" prop="author">
          <el-input v-model="form.author"></el-input>
        </el-form-item>
        <el-form-item label="ISBN" prop="isbn">
          <el-input v-model="form.isbn"></el-input>
        </el-form-item>
        <el-form-item label="单价" prop="price">
          <el-input v-model="form.price"></el-input>
        </el-form-item>
        <el-form-item label="使用课程" prop="teacherCourseId">
          <el-select v-model="form.teacherCourseId" placeholder="请选择使用课程">
            <el-option label="java" value="java"></el-option>
            <el-option label="SQL" value="sql"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="教材简介" prop="remark1">
          <el-input type="textarea" v-model="form.remark1"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="submitForm('form')">立即创建</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>
<style>
</style>
<script>
    export default{
        name : 'newTeachMaterial',
        data(){
            return{
                form: {
                    textbookId:'',
                    textbookName:'',
                    publishingHouse:'',
                    author:'',
                    isbn:'',
                    price:'',
                    teacherCourseId:[],
                    remark1:''
                },
                rules: {
                    textbookId:[
                        { required: true, message: '请输入活动名称', trigger: 'blur' }
                    ],
                    textbookName:[
                        { required: true, message: '请输入活动名称', trigger: 'blur' }
                    ],
                    publishingHouse:[
                        { required: true, message: '请输入活动名称', trigger: 'blur' }
                    ],
                    author:[
                        { required: true, message: '请输入活动名称', trigger: 'blur' }
                    ],
                    isbn:[
                        { required: true, message: '请输入活动名称', trigger: 'blur' }
                    ],
                    price:[
                        { required: true, message: '请输入活动名称', trigger: 'blur' }
                    ],
                    teacherCourseId:[
                        { required: true, message: '请输入活动名称', trigger: 'blur' }
                    ],
                    remark1:[
                        { required: true, message: '请输入活动名称', trigger: 'blur' }
                    ]
                }
            }
        },
        components:{
        },
        mounted:function(){
        },
        methods:{
            submitForm(formName) {
              this.$refs[formName].validate((valid) => {
                if (valid) {
                  alert('submit!');
                } else {
                  console.log('error submit!!');
                  return false;
                }
              });
            },
            getRes() {

            },
            postRes:function() {
              this.$http.post('http://192.168.1.109/jsonData/res.php', {"name" : "ava"}).then(response => {

                // get status
                // get status text
                // get 'Expires' header
                // get body data

              }, response => {
                // error callback
              });
            }
        }
    }
</script>
